//
//  BrushStartVC.m
//  BrushFace
//
//  Created by timer_q on 15/12/31.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "BrushStartVC.h"
#import "NavHelper.h"
#import "LCActionSheet.h"
#import "BrushingVC.h"

@interface BrushStartVC ()<LCActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>

@end

@implementation BrushStartVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.navBar setTitle:@"刷脸识钱途"];
    [self.navBar setLeftBtn:NAV_BAR_LEFT_BTN_TYPE_BLUE];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 20, 60, 44)];
    [button setTitle:@"跳过" forState:UIControlStateNormal];
    [button setTitleColor:ColorDefaultBlue forState:UIControlStateNormal];
    [button addTarget:self action:@selector(jumpGoBorrow) forControlEvents:UIControlEventTouchUpInside];
    [self.navBar setRightView:button];
}
- (IBAction)startBrushButtonClick:(id)sender {
    LCActionSheet *sheet = [[LCActionSheet alloc] initWithTitle:nil buttonTitles:@[@"拍照",@"从手机相册选择"] redButtonIndex:3 delegate:self];
    [sheet show];
}
- (void)jumpGoBorrow{
    [NavHelper gotoIWillBorrowVC];
}

- (void)actionSheet:(LCActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex{
    switch (buttonIndex) {
        case 0:
        {
            [self callCameraWithType:0];
        }
            break;
        case 1:
        {
            [self callCameraWithType:1];
        }
            break;
        default:
            break;
    }
}

- (void)callCameraWithType:(NSInteger)type{
    UIImagePickerControllerSourceType sourceType;
    if (type==0) {
        sourceType = UIImagePickerControllerSourceTypeCamera;
    }else{
        sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
    }
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];//初始化
    picker.delegate = self;
    picker.allowsEditing = NO;//设置可编辑
    picker.sourceType = sourceType;
    [self presentViewController:picker animated:YES completion:^{
        
    }];//进入照相界面

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    
    [picker dismissViewControllerAnimated:YES completion:^{}];
    UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
    BrushingVC * _vc;
    if (SCREEN_WIDTH == 320) {
        _vc = [[BrushingVC alloc]initWithNibName:@"BrushingVC" bundle:nil];
    }else if(SCREEN_WIDTH == 375){
        _vc = [[BrushingVC alloc]initWithNibName:@"BrushingVC4.7" bundle:nil];
    }else{
        _vc = [[BrushingVC alloc]initWithNibName:@"BrushingVC5.5" bundle:nil];
    }
    _vc.currentImage = image;
    [_vc setHidesBottomBarWhenPushed:YES];
    [self.navigationController pushViewController:_vc animated:YES];
    
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
